﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pipes.Collections
{
  public static class EnumerableExtensions
  {
    public static IEnumerable<IndexedElement<T>> Subset<T>(this IEnumerable<T> source, int start, int count)
    {
      int i = 0;
      var enumerator = source.GetEnumerator();
      while (enumerator.MoveNext() && i < (start + count))
      {
        if (i >= start)
        {
          yield return new IndexedElement<T>(i, enumerator.Current);
        }
        i++;
      }
    }
  }
}
